class RestApi {
    //用户数据示例
    customers = [
        {
            id: '08c0a6ec-a42b-47b2-bb1e-15e0f5f9a19a',
            name: '赵金波',
            password: '123',
            avatar: '/static/avater/zjb.jpg',
            email: 'Mattie@goeasy.io',
            phone: '138xxxxxxxx',
        },
        {
            id: '3bb179af-bcc5-4fe0-9dac-c05688484649',
            name: '董绍勋',
            password: '123',
            avatar: '/static/avater/dsx.jpg',
            email: 'Wallace@goeasy.io',
            phone: '138xxxxxxxx',
        },
        {
            id: 'fdee46b0-4b01-4590-bdba-6586d7617f95',
            name: '苏塞',
            password: '123',
            avatar: '/static/avater/ss.jpg',
            email: 'Tracy@goeasy.io',
            phone: '138xxxxxxxx',
        },
        {
            id: '33c3693b-dbb0-4bc9-99c6-fa77b9eb734g',
            name: '高晶磊',
            password: '123',
            avatar: '/static/avater/gjl.jpg',
            email: 'Juanita@goeasy.io',
            phone: '138xxxxxxxx',
        },
    ];
    // 店铺
    shops = [
        {
            name: 'GoEasy食品自营',
            avatar: '/static/images/shop1.png',
            id: 'shop01',
            goods: ['/static/images/goods1-1.jpg', '/static/images/goods1-2.jpg', '/static/images/goods1-3.jpg',]
        },
        {
            name: 'GoEasy家具生活自营',
            avatar: '/static/images/shop2.png',
            id: 'shop02',
            goods: ['/static/images/goods2-1.jpg', '/static/images/goods2-2.jpg', '/static/images/goods2-3.jpg',]
        },
        {
            name: 'GoEasy电器自营',
            avatar: '/static/images/shop3.png',
            id: 'shop03',
            goods: ['/static/images/goods3-1.jpg', '/static/images/goods3-2.jpg', '/static/images/goods3-3.jpg',]
        },
        {
            name: '米忽悠',
            avatar: '/static/images/shop3.png',
            id: 'mhy',
            goods: ['/static/images/goods3-1.jpg', '/static/images/goods3-2.jpg', '/static/images/goods3-3.jpg',]
        },
    ];
    // 客服代表
    agents = [{
        id: '6ec2c1df-24f4-4c33-a16c-d0c9de69ac09',
        name: '银狼',
        password: '123',
        avatar: '/static/avater/yl.png',
        email: 'Kim@goeasy.io',
        phone: '138xxxxxxxx',
        shopId: 'shop01'
    },
    {
        id: 'yinlang',
        name: '银狼',
        password: '1234',
        avatar: '/static/avater/yl.png',
        email: 'yinlang@goeasy.io',
        phone: '15106998957',
        shopId: 'mhy'
    },
    {
        id: '9c4ebaa6-e447-49cc-8091-34fdc25a3504',
        name: 'type-c符玄',
        password: '123',
        avatar: '/static/avater/fx.jpg',
        email: 'Harry@goeasy.io',
        phone: '138xxxxxxxx',
        shopId: 'shop02'
    },
    {
        id: '6c751842-545d-4da0-a203-49c31a78d202',
        name: '镜流',
        password: '123',
        avatar: '/static/avater/jl.jpg',
        email: 'Belle@goeasy.io',
        phone: '138xxxxxxxx',
        shopId: 'shop03'
    }
    ];
    // 订单
    orders = [
        {
            id: '252364104325',
            url: '/static/images/goods1-1.jpg',
            name: '青桔柠檬气泡美式',
            price: '￥23',
            count: 1
        },
        {
            id: '251662058022',
            url: '/static/images/goods1-2.jpg',
            name: '咸柠七',
            price: '￥8',
            count: 2
        },
        {
            id: '250676186141',
            url: '/static/images/goods1-3.jpg',
            name: '黑糖波波鲜奶茶',
            price: '￥12',
            count: 1
        }
    ];

    findShops() {
        return this.shops;
    }

    findCustomerById(customerId) {
        return this.customers.find((customer) => customer.id === customerId);
    }

    findCustomer(username, password) {
        return this.customers.find((customer) => customer.name === username && customer.password === password);
    }

    findAgents() {
        this.agents.forEach((agent) => {
            agent.shop = this.findShopById(agent.shopId);
        })
        return this.agents;
    }

    findShopById(shopId) {
        return this.shops.find((shop) => shop.id === shopId);
    }

    // findAgent(username, password) {
    //     return this.agents.find((agent) => agent.name === username && agent.password === password);
    // }
    findAgent(shopId, username, password) {
        return this.agents.find((agent) => agent.name === username && agent.password === password && agent.shopId === shopId);
    }

    findAgentById(agentId) {
        return this.agents.find((agent) => agent.id === agentId);
    }

    getOrderList() {
        return this.orders;
    }

    findCustomers() {
        return this.customers;
    }

}

export default new RestApi();
